//
//  BBYHandAreaViewController.m
//  BearSiX
//
//  Created by Tom on 16/3/26.
//  Copyright © 2016年 Tom. All rights reserved.
//

#import "BBYHandAreaViewController.h"

@interface BBYHandAreaViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSArray *areaArr;
@end

@implementation BBYHandAreaViewController
-(NSArray *)areaArr{

    if (!_areaArr) {
        _areaArr = @[@"广渠门",@"西单",@"通州",@"亦庄",@"大兴",@"国贸",@"崇文门",@"西城",@"东单"];
    }
    return _areaArr;
}
-(UITableView *)tableView{

    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, WINSIZEHEIGHT)];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = [[UIView alloc]init];
        
    }
    return _tableView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"接单点";
    [self.view addSubview:self.tableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return self.areaArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *indeir = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indeir];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:indeir];
        cell.tintColor = [UIColor colorWithHexString:@"ee002d"];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%@",self.areaArr[indexPath.row]];
    if ([cell.textLabel.text isEqualToString:self.areaStr]) {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    }else{
    
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    self.areaStr = [NSString stringWithFormat:@"%@",self.areaArr[indexPath.row]];
    [self.tableView reloadData];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
